package com.hrbxlh.virtualization.controller;

import com.hrbxlh.virtualization.param.StatisticQueryParam;
import com.hrbxlh.virtualization.result.Result;
import com.hrbxlh.virtualization.service.StatisticService;
import com.hrbxlh.virtualization.util.ObjectUtil;
import com.hrbxlh.virtualization.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author cheer
 */
@RestController
@RequestMapping("/statistic")
public class StatisticController {

    @Autowired
    private StatisticService statisticService;

    /**
     * 查看实验时长
     *
     * @return 实验时长，单位为秒
     */
    @RequestMapping(value = "/query", method = RequestMethod.GET)
    public Result<Map<String, Object>> getExperimentTime(StatisticQueryParam statisticQueryParam) {
        statisticQueryParam.setStuorteaId(SessionUtil.getStuorteaId());
        Long experimentTime = statisticService.getExperimentTime(statisticQueryParam);
        return Result.success(ObjectUtil.build().addObject("experimentTime", experimentTime).map());
    }
}
